import React, { Component } from 'react';
import "../styles/MyList.scss"

import * as service from '../api/index'

class MyList extends Component {
  constructor(props) {
    super(props)
    this.state = {
      list: [],
      list2: []
    }
  }

  async componentDidMount() {
    var res = await service.index_nav()
    console.log(res.data.list);
    if (res.data.code == 200) {
      this.setState({ list: res.data.list })
    }
    var res2 = await service.index_goodlist()
    console.log(res2.data.list);
    if (res2.data.code == 200) {
      this.setState({ list2: res2.data.list })
    }
  }

  render() {
    return (
      <div className='list'>
        <p>1分抵1元。请您点击此处查看《购物须知》</p>
        <div className='tasklist'>
          {
            this.state.list.map((item, index) => {
              return (
                <div className="item" key={index} >
                  <img src={item.pic} alt="" />
                  <div>{item.name}</div>
                </div>

              )
            })
          }
        </div>

      </div>
    );
  }
}

export default MyList;